package com.gitee.c0dehvb.reactive.sample.r2dbc.connection;

import io.r2dbc.spi.Batch;
import io.r2dbc.spi.Connection;
import io.r2dbc.spi.ConnectionMetadata;
import io.r2dbc.spi.IsolationLevel;
import io.r2dbc.spi.Statement;
import io.r2dbc.spi.ValidationDepth;
import org.reactivestreams.Publisher;

/**
 * 连接代理
 * @author LiYilin
 * @since 2022/6/15 9:43 PM
 **/
public class ConnectionDelegator implements Connection {
    protected final Connection connection;

    public ConnectionDelegator(Connection connection) {
        this.connection = connection;
    }

    @Override
    public Batch createBatch() {
        return connection.createBatch();
    }

    @Override
    public Statement createStatement(String sql) {
        return connection.createStatement(sql);
    }

    @Override
    public Publisher<Void> beginTransaction() {
        return connection.beginTransaction();
    }

    @Override
    public Publisher<Void> close() {
        return connection.close();
    }

    @Override
    public Publisher<Void> commitTransaction() {
        return connection.commitTransaction();
    }

    @Override
    public Publisher<Void> createSavepoint(String name) {
        return connection.createSavepoint(name);
    }

    @Override
    public boolean isAutoCommit() {
        return connection.isAutoCommit();
    }

    @Override
    public ConnectionMetadata getMetadata() {
        return connection.getMetadata();
    }

    @Override
    public IsolationLevel getTransactionIsolationLevel() {
        return connection.getTransactionIsolationLevel();
    }

    @Override
    public Publisher<Void> releaseSavepoint(String name) {
        return connection.releaseSavepoint(name);
    }

    @Override
    public Publisher<Void> rollbackTransaction() {
        return connection.rollbackTransaction();
    }

    @Override
    public Publisher<Void> rollbackTransactionToSavepoint(String name) {
        return connection.rollbackTransactionToSavepoint(name);
    }

    @Override
    public Publisher<Void> setAutoCommit(boolean autoCommit) {
        return connection.setAutoCommit(autoCommit);
    }

    @Override
    public Publisher<Void> setTransactionIsolationLevel(IsolationLevel isolationLevel) {
        return connection.setTransactionIsolationLevel(isolationLevel);
    }

    @Override
    public Publisher<Boolean> validate(ValidationDepth depth) {
        return connection.validate(depth);
    }
}
